*Replication commands for:
*Owsiak, Andrew P, Paul F Diehl, and Gary Goertz. 2017. Border settlement and the movement toward negative peace. CMPS.

*use "/Owsiak Diehl Goertz 2017 CMPS Replication Data.dta", clear
set more off

*Part A: Descriptive results
*Tab relationships, but only if we have settled border data. This isolates relationship data within our analysis.
tab relationship if relationship<0.75 & relationship!=. & settle!=.
tab settle negpeace, r col chi2 gamma
tab civilwarab negpeace if settle!=., r col chi2 gamma

*Part B: Bi-/Multi-variate analysis (use settle in second command to keep focus on data in the analyses).
*Table 1, Models 1-4
sort cdyad year
tsset cdyad year
logit negpeace L.relationship if relcat!=. & settle!=. & year>1945, robust
logit negpeace L.relationship settle if relcat!=. & year>1945, robust
logit negpeace L.relationship settle jtdem relcaps civilwarab obs if relcat!=. & year>1945, robust
logit negpeace L.relationship settle jtdem relcaps civilwarab obs obs2 obs3 if relcat!=. & year>1945, robust

*Table 2
estsimp logit negpeace L.relationship settle jtdem relcaps civilwarab obs obs2 obs3 if relcat!=. & year>1945, robust
setx L.relationship mean settle 0 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx L.relationship mean settle 1 jtdem 1 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx L.relationship mean settle 1 jtdem 0 relcaps 2.780 civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx L.relationship mean settle 1 jtdem 0 relcaps 81.290 civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 0 obs mean obs2 mean obs3 mean
simqi
setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 1 obs 15 obs2 225 obs3 3375
simqi
setx L.relationship mean settle 1 jtdem 0 relcaps mean civilwarab 1 obs 54 obs2 2916 obs3 157464
simqi

drop b1-b9

*In text statistics:
tab shifttoany if settle!=. & year>1945 & relcat!=.
tab shiftfromriv if settle!=. & year>1945 & relcat!=.


*Table 3: Transitions
logit shiftfromriv settle if L.anyriv==1 & relcat!=. & year>1945, robust
logit shiftfromriv settle jtdem relcaps civilwarab obs if L.anyriv==1 & relcat!=. & year>1945, robust
logit shiftfromriv settle jtdem relcaps civilwarab obs obs2 obs3 if L.anyriv==1 & relcat!=. & year>1945, robust
logit shifttoany settle if L.relationship==0.50 & relcat!=. & year>1945, robust
logit shifttoany settle jtdem relcaps civilwarab obs if L.relationship==0.50 & relcat!=. & year>1945, robust
logit shifttoany settle jtdem relcaps civilwarab obs obs2 obs3 if L.relationship==0.50 & relcat!=. & year>1945, robust

*Table 4
estsimp logit shiftfromriv settle jtdem relcaps civilwarab obs obs2 obs3 if L.anyriv==1 & relcat!=. & year>1945, robust
setx settle 0 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx settle 1 jtdem 1 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 jtdem 0 relcaps 1.936 civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx settle 1 jtdem 0 relcaps 15.229 civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 jtdem 0 relcaps mean civilwarab 0 obs mean obs2 mean obs3 mean
simqi
setx settle 1 jtdem 0 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 jtdem 0 relcaps mean civilwarab 1 obs 19 obs2 361 obs3 6859
simqi
setx settle 1 jtdem 0 relcaps mean civilwarab 1 obs 75 obs2 5625 obs3 421875
simqi
drop b1-b8
 
*Table 5
estsimp logit shifttoany settle relcaps civilwarab obs obs2 obs3 if L.relationship==0.50 & relcat!=. & year>1945, robust
setx settle 0  relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx settle 1 relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 relcaps 2.971 civilwarab 1 obs mean obs2 mean obs3 mean
simqi
setx settle 1 relcaps 102.631 civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1  relcaps mean civilwarab 0 obs mean obs2 mean obs3 mean
simqi
setx settle 1  relcaps mean civilwarab 1 obs mean obs2 mean obs3 mean
simqi

setx settle 1 relcaps mean civilwarab 1 obs 15 obs2 225 obs3 3375
simqi
setx settle 1 relcaps mean civilwarab 1 obs 52 obs2 2704 obs3 140608
simqi
drop b1-b7


